package com.dz.order.controller;

import com.dz.common.base.BaseApiService;
import com.dz.common.base.ResponseBase;
import com.dz.order.domain.vo.CartParamVO;
import com.dz.order.service.CartService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName : CartController
 * @Description :
 * @Author : ming
 * @Date: 2021-03-08 14:56
 **/
@RestController
@RequestMapping("/cart")
@Api(tags = "购物车管理")
public class CartController extends BaseApiService {
    @Autowired
    private CartService cartService;

    @PostMapping("add")
    public ResponseBase add(@RequestBody CartParamVO vo){
        String username="dzm";
        //将商品加入购物车
        try {
            cartService.add(vo.getNum(),vo.getId(),username);
            return setResultSuccess("加入购物成功!");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return setResultError("加入购物失败!");
    }
}
